﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace PopupWinTool.Views
{
    /// <summary>
    /// 测试窗体.xaml 的交互逻辑
    /// </summary>
    public partial class 测试窗体 : UserControl
    {
        public 测试窗体()
        {
            InitializeComponent();
        }
        private void AppenText(string msg)
        {
            //Application.Current.Dispatcher.Invoke(() =>
            //{
            //    tbPrompt.Text = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}  {msg}";
            //});
            tbPrompt.Text = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}  {msg}";
        }
        /// <summary>
        /// 传递数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn1_Click(object sender, RoutedEventArgs e)
        {
            this.Tag = tb.Text.ToString();
            AppenText($"设置测试值成功。。。");
        }
        /// <summary>
        /// Pass按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPass_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var win = this.Parent as Window;
                if (win != null)
                {
                    win.DialogResult = true;
                    win.Close();
                }
            }
            catch (Exception ex)
            {
                AppenText($"Pass异常，{ex.Message}");
            }
        }
        /// <summary>
        /// Fail按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnFail_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var win = this.Parent as Window;
                if (win != null)
                {
                    win.DialogResult = false;
                    win.Close();
                }
            }
            catch (Exception ex)
            {
                AppenText($"Fail异常，{ex.Message}");
            }
        }
    }
}
